package youxiao.bytezon.utils;

import javax.servlet.http.HttpServletRequest;

import com.google.common.primitives.Ints;

public class PageUtil {

	public static int getPageNum(HttpServletRequest request) {
		int page = parsePageNum(request.getParameter("page"));
		return page - 1;
	}
	
	public static int parsePageNum(String pageNum) {
		int page = 1;
		try {
			page = Ints.tryParse(pageNum);
		} catch (Exception ex) {
			
		}
		page = page < 1 ? 1 : page;
		return page;
	}
	
}
